package com.study.config;

import com.study.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册Token拦截器
        registry.addInterceptor(loginInterceptor)
                // 需要拦截的路径
                //.addPathPatterns("/api/**")
                // 排除不需要拦截的路径（例如登录接口）
                .excludePathPatterns("/login", "/register", "/getCode");
    }
}
